/**
 * Created by user on 2018/4/12.
 */
import { MenuActions } from '../actions'
const global_state = {
  collapsed: false,
  openKey: [],
  selectKey: []
}

const GlobalState = (state = global_state, action) => {
  switch (action.type) {
    case MenuActions.MenuType.toggle_collapsed:
      return Object.assign({}, state, {
        collapsed: action.collapsed
      })
    case MenuActions.MenuType.change_open_key:
      return Object.assign({}, state, {
        openKey: action.key ? [action.key] : []
      })
    case MenuActions.MenuType.change_select_key:
      return Object.assign({}, state, {
        selectKey: action.key ? [action.key] : []
      })
    default:
      return state
  }
}

export default GlobalState
